<?php

	##################################################
	#
	# Copyright (c) 2004-2006 OIC Group, Inc.
	# Written and Designed by James Hunt
	#
	# This file is part of Exponent
	#
	# Exponent is free software; you can redistribute
	# it and/or modify it under the terms of the GNU
	# General Public License as published by the Free
	# Software Foundation; either version 2 of the
	# License, or (at your option) any later version.
	#
	# GPL: http://www.gnu.org/licenses/gpl.txt
	#
	##################################################
	/**
	* Change logs
	* Jan 29 2011, trungdt - support logout openid
	* June 9, 2011 - trungdt - add auto clear html cache after logout
	* Oct 26, 2011 - trungdt - Support Olark : clear all cookies when logout
	*/
	if (!defined('EXPONENT')) exit('');

	if (!defined('SYS_USERS')) require_once('subsystems/users.php');
	exponent_users_logout();
	aboid_Logout();
	exponent_permissions_clear();
	exponent_sessions_unset('uilevel');
	exponent_sessions_clearCurrentUserSessionCache();
	// Oct 26, 2011 - trungdt - For support Olark, we clear all cookies when logout
	
	/**
	* June 9, 2011 - trungdt - clear all cache
	*/
	// Oct 14, 2011 -trungdt - remove function clear cache automatically, add button clear cache in Quick Link Menu
	//$mask = BASE."/tmp/views_c/_*.php";
	//array_map( "unlink", glob( $mask ) );
	/**
	* June 9, 2011 - trungdt - clear all cache - end
	*/
	//TODO: Maxims initial anonymous user implementation
	//exponent_users_login("anonymous", "anonymous");
	//exponent_flow_redirect();
	// For Olark support, we should clear cookie wscid
	$ticket=exponent_sessions_getTicketString();
	$logout_url=exponent_core_makeLink(array(
		"module"=>"loginmodule",
		"action"=>"logout"
	));
	$redirect_to=exponent_flow_get();
	if ($redirect_to == $logout_url)
		$redirect_to=exponent_core_makeLink(array('section'=>SITE_DEFAULT_SECTION));
?>
<script language="javascript">
	document.cookie = "wcsid=''; expires=Thu, 01 Jan 1970 00:00:00 GMT";
	window.location="<?php echo $redirect_to;?>";
</script>